package com.site.common.filter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.web.method.HandlerMethod;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * AbstractBaseFilter过滤器
 */
public abstract class AbstractBaseFilter<T> implements BaseFilter<T>{

    protected final Logger logger = LoggerFactory.getLogger(this.getClass());

    /**
     * 公共调用
     * @param request
     * @param response
     * @param handlerMethod
     * @return
     * @throws Throwable
     */
    @Override
    public T doHandlerFilter(HttpServletRequest request, HttpServletResponse response, HandlerMethod handlerMethod, ApplicationContext context) throws Throwable{
        return this.execute(request,response,handlerMethod,context);
    }

    /**
     * 业务执行
     * @param request
     * @param response
     * @param handlerMethod
     * @param context
     * @return
     */
    protected abstract T execute(HttpServletRequest request, HttpServletResponse response, HandlerMethod handlerMethod, ApplicationContext context);
}
